#!/bin/bash

if [[ "$(uname -s)" == "Linux" ]]; then
	curl -L -O "https://mirrors.nju.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-$(uname)-$(uname -m).sh"
	bash Miniforge3-$(uname)-$(uname -m).sh -b && rm -rf Miniforge3-$(uname)-$(uname -m).sh
	mamba_path=$HOME/miniforge3/condabin/mamba
	$mamba_path init "$(basename "${SHELL}")"
	conda_path=$HOME/miniforge3/condabin/conda
	$conda_path config --set show_channel_urls yes
	$conda_path config --set auto_activate_base false
	$conda_path config --set custom_channels.conda-forge https://mirrors.nju.edu.cn/anaconda/cloud/
	$HOME/miniforge3/bin/python3 -m pip config set global.index-url https://mirrors.nju.edu.cn/pypi/web/simple
	$HOME/miniforge3/bin/python3 -m pip config set install.trusted-host mirrors.nju.edu.cn/pypi/web/simple
	echo 'export PATH="$HOME"/miniforge3/bin:${PATH}' >>~/.zprofile
	echo 'export PATH="$HOME"/miniforge3/bin:${PATH}' >>~/.bashrc
	export PATH="$HOME"/miniforge3/bin:${PATH}
fi

if [[ "$(uname -s)" == "Darwin" ]]; then
	curl -L -O "https://mirrors.nju.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-$(uname)-$(uname -m).sh"
	bash Miniforge3-$(uname)-$(uname -m).sh -b && rm -rf Miniforge3-$(uname)-$(uname -m).sh
	mamba_path=$HOME/miniforge3/condabin/mamba
	$mamba_path init "$(basename "${SHELL}")"
	conda_path=$HOME/miniforge3/condabin/conda
	$conda_path config --set show_channel_urls yes
	$conda_path config --set auto_activate_base false
	$conda_path config --set custom_channels.conda-forge https://mirrors.nju.edu.cn/anaconda/cloud/
	$HOME/miniforge3/bin/python3 -m pip config set global.index-url https://mirrors.nju.edu.cn/pypi/web/simple
	$HOME/miniforge3/bin/python3 -m pip config set install.trusted-host mirrors.nju.edu.cn/pypi/web/simple
	echo 'export PATH="$HOME"/miniforge3/bin:${PATH}' >>~/.zprofile
	echo 'export PATH="$HOME"/miniforge3/bin:${PATH}' >>~/.bashrc
	export PATH="$HOME"/miniforge3/bin:${PATH}
fi

: <<COMMENT

bash -c "$(curl -fsSL https://gitee.com/hevey88/install_script/raw/main/install_miniforge.sh)"

COMMENT
